package com.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.crm.dao.BizProductMapper;
import com.crm.model.BizProduct;
import com.crm.service.BizProductService;
import com.crm.util.UUIDUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
public class BizProductServiceImpl extends BaseServiceImpl<BizProduct> implements BizProductService{
	
	@Autowired
	private BizProductMapper bizProductMapper;
	
	@Override
	public int insert(BizProduct record) {
		
		String uuid = UUIDUtil.getUUID();
		record.setProductId(uuid);;
		
		return super.insert(record);
	}

	@Override
	public List<BizProduct> selectAllByProfessional(Page<BizProduct> page, BizProduct record) {
		
		PageHelper.startPage(page.getPageNum(), page.getPageSize(), "create_date desc");
		
		return bizProductMapper.selectAllByProfessional(record);
	}

	@Override
	public List<BizProduct> selectAllByEducation(Page<BizProduct> page, BizProduct record) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize(), "create_date desc");
		
		return bizProductMapper.selectAllByEducation(record);
	}

	@Override
	public List<BizProduct> selectAllByProfessionalPrice(Page<BizProduct> page, BizProduct record) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize(), "create_date desc");
		
		return bizProductMapper.selectAllByProfessionalPrice(record);
	}

	@Override
	public List<BizProduct> selectAllByEducationPrice(Page<BizProduct> page, BizProduct record) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize(), "create_date desc");
		
		List<BizProduct> list = bizProductMapper.selectAllByEducationPrice(record);
		
		return list;
				
	}
	public List<BizProduct> selectByUsPrice(BizProduct record) {
		// TODO Auto-generated method stub
		return bizProductMapper.selectByUsPrice(record);
	}

	@Override
	public List<BizProduct> selectAllProfessional(Page<BizProduct> page,BizProduct t) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page.getPageNum(), page.getPageSize(), "bp.create_date desc");
		
		return bizProductMapper.selectAllProfessionalByWhere(t);
	}

	@Override
	public List<BizProduct> selectByUsForSchool(BizProduct record) {
		// TODO Auto-generated method stub
		return bizProductMapper.selectByUsForSchool(record);
	}

	@Override
	public List<BizProduct> selectByUsForMajor(BizProduct t) {
		// TODO Auto-generated method stub
		return bizProductMapper.selectByUsForMajor(t);
	}

	@Override
	public List<BizProduct> selectByUsForClass(BizProduct t) {
		// TODO Auto-generated method stub
		return bizProductMapper.selectByUsForClass(t);
	}

	@Override
	public List<BizProduct> selectByUsForPrice(BizProduct t) {
		// TODO Auto-generated method stub
		return bizProductMapper.selectByUsForPrice(t);
	}
}
